home *** CD-ROM | disk | FTP | other *** search
/ Long Ban 3 / Long Ban 3 - Disc 2.iso / mac / DISK2 / DATA / cont2.Dxr / 00006_VSlider Script.ls < prev    next >
Encoding:
Text File  |  1997-03-22  |  1.9 KB  |  65 lines

  1. property slidermin, slidermax, thumbsprite, barleft, bartop, barright, barbottom, barwidth, barheight, sliderscale
  2.  
  3. on new me, smin, smax, bleft, btop, bright, bbottom, thumbsp, pos
  4.   set the slidermin of me to smin
  5.   set the slidermax of me to smax
  6.   set the thumbsprite of me to thumbsp
  7.   set the barleft of me to bleft
  8.   set the barright of me to bright
  9.   set the bartop of me to btop
  10.   set the barbottom of me to bbottom
  11.   set the barwidth of me to 1.0 * (bright - bleft)
  12.   set the barheight of me to 1.0 * (bbottom - btop)
  13.   set the sliderscale of me to 1.0 * (the barheight of me / (smax - smin))
  14.   set the locV of sprite thumbsp to btop + ((pos - smin) * the sliderscale of me)
  15.   set the locH of sprite thumbsp to bleft + (the barwidth of me / 2)
  16.   updateStage()
  17.   return me
  18. end
  19.  
  20. on movethumb me
  21.   repeat while the stillDown
  22.     set v to the mouseV
  23.     if v > the barbottom of me then
  24.       set posy to the barbottom of me
  25.     else
  26.       if v < the bartop of me then
  27.         set posy to the bartop of me
  28.       else
  29.         set posy to v
  30.       end if
  31.     end if
  32.     set the locV of sprite the thumbsprite of me to posy
  33.     set y to getthumbposition(me)
  34.     set the locV of sprite 2 to 920 - y
  35.     updateStage()
  36.   end repeat
  37.   set y to getthumbposition(me)
  38.   set wk to integer(y) mod 80
  39.   if wk < 40 then
  40.     set y to integer(y) - wk
  41.   else
  42.     set y to integer(y) - wk + 80
  43.   end if
  44.   setthumbposition(me, y)
  45.   set the locV of sprite 2 to 920 - y
  46.   updateStage()
  47. end
  48.  
  49. on setthumbposition me, v
  50.   if v > the slidermax of me then
  51.     set v to the slidermax of me
  52.   else
  53.     if v < the slidermin of me then
  54.       set v to the slidermin of me
  55.     end if
  56.   end if
  57.   set y to (the sliderscale of me * v) + the bartop of me
  58.   set the locV of sprite the thumbsprite of me to y
  59. end
  60.  
  61. on getthumbposition me
  62.   set w to 1.0 * (the locV of sprite the thumbsprite of me - the bartop of me)
  63.   return (w / the sliderscale of me) + the slidermin of me
  64. end
  65.